package thread;

public class Demo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("thread running");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println("something wrong with t");
                }
            }
            System.out.println("t 线程结束");
        });
        t.start();
        //main 线程阻塞等待 t 线程
        t.join();

        System.out.println("main 线程结束");
    }
}
